package com.meilai.project.constant;

import lombok.Getter;

/**
 * @Author yxg
 * @Date 2020/7/16 13:57
 */
@Getter
public enum InstallTypeEnum {
    INSTALL(1, 4, "新安装"),
    PUBLISH(2, 1, "上刊"),
    UNPUBLISH(3, 2, "下刊"),
    CHECK(4, 3, "巡检"),
    REPAIR(5, 5,  "维修"),

    APPLYREPAIR(6, 6,  "维修申报"),
    REPLACE(7, 7,  "换画"),

    INTERMEDIATE_MONITORING(8, 8,  "中间监播");

    private Integer installType;
    private Integer oldInstallType; // 原系统类型id,由于需要尽量不修改app，关于app的接口需要设置成原类型id
    private String installTypeName;

    public static InstallTypeEnum parse(Integer type) {
        for (InstallTypeEnum o : InstallTypeEnum.values()) {
            if (o.getInstallType().equals(type)) {
                return o;
            }
        }
        return null;
    }

    public static String getName(Integer type) {
        for (InstallTypeEnum o : InstallTypeEnum.values()) {
            if (o.getInstallType().equals(type)) {
                return o.installTypeName;
            }
        }
        return null;
    }

    public static Integer getOldType(Integer type){
        for (InstallTypeEnum o : InstallTypeEnum.values()) {
            if (o.getInstallType().equals(type)) {
                return o.oldInstallType;
            }
        }
        return null;
    }

    public static Integer getType(Integer oldType){
        for (InstallTypeEnum o : InstallTypeEnum.values()) {
            if (o.getOldInstallType().equals(oldType)) {
                return o.installType;
            }
        }
        return null;
    }

    InstallTypeEnum(Integer installType, Integer oldInstallType, String installTypeName) {
        this.installType = installType;
        this.oldInstallType = oldInstallType;
        this.installTypeName = installTypeName;
    }
}
